<!--  -->
<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i>
                    {{pageTitle}}
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <acc-set-card></acc-set-card>
        <div class="container" :style="{'min-height': containerHeight + 'px'}">
            <div class="handle-box flex flex-center">
                <el-button type="primary" icon="el-icon-folder" @click="saveEdit()">关闭</el-button>
            </div>
            <div style="margin-top:10px;border:1px solid">
                <div style="margin:10px;">
                    <vxe-table
                        keep-source
                        stripe
                        border
                        show-footer
                        :footer-method="footerMethod"
                        resizable
                        ref="xTable"
                        :data="tableData"
                    >
                        <vxe-table-column field="id" title="序号" type="index" align="center"></vxe-table-column>
                        <vxe-table-column field="period" title="会计期间"></vxe-table-column>
                        <vxe-table-column field="subName" title="科目"></vxe-table-column>
                        <vxe-table-column field="drFlag" title="借贷方向"></vxe-table-column>
                        <vxe-table-column field="beginAmt" title="本币期初金额"></vxe-table-column>
                        <vxe-table-column field="debitAmt" title="本位币借方金额"></vxe-table-column>
                        <vxe-table-column field="crebitAmt" title="本位币贷方金额"></vxe-table-column>
                        <vxe-table-column field="endAmt" title="本位币期末金额"></vxe-table-column>
                        <vxe-table-column field="currId" title="币别"></vxe-table-column>
                        <vxe-table-column field="rate	" title="汇率"></vxe-table-column>
                        <vxe-table-column field="beginAmtOc" title="原币期初金额"></vxe-table-column>
                        <vxe-table-column field="debitAmtOc" title="原币借方金额"></vxe-table-column>
                        <vxe-table-column field="crebitAmtOc" title="原币贷方金额"></vxe-table-column>
                        <vxe-table-column field="" title="原币期末金额"></vxe-table-column>
                        <vxe-table-column field="empName" title="人员"></vxe-table-column>
                        <vxe-table-column field="deptName" title="部门"></vxe-table-column>
                        <vxe-table-column field="tranName" title="往来"></vxe-table-column>
                        <vxe-table-column field="proName" title="项目"></vxe-table-column>

                        
                    </vxe-table>
                </div>
            </div> 
        </div>
    </div>
</template>

<script>
import appMain from '../../../utils/app_main.js';
import bus from '../../../components/common/bus'
import XEUtils from 'xe-utils';
var _ = require('lodash');
let moneyReg = /^(([1-9]{1}\d*)|(0{1}))(\.\d{2})$/;
export default {
    data() {
        return {
            pageTitle: '',
            containerHeight: '',
            isUpdate: false, //是否是更新
            currentRow: '',
            tableData: [],
        };
    },
    methods: {
      
        closeDialog (data) {
            this.showBillSearch = false
        },
        close() {
            this.$emit('close', {
                showDialog: false
            });
        },
        //表脚
        footerMethod({ columns, data }) {
            return [
                columns.map((column, columnIndex) => {
                    if (columnIndex === 0) {
                        return '合计';
                    }
                    if (columnIndex === 4) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'beginAmt')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 5) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'debitAmt')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 6) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'crebitAmt')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 7) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'endAmt')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }

                    if (columnIndex === 10) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'beginAmtOc')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 11) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'debitAmtOc')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 12) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, 'crebitAmtOc')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    if (columnIndex === 13) {
                        //console.log('columns', data);
                        let coin = `${XEUtils.sum(data, '')}`;
                        // this.ruleForm.total = coin;
                        return coin + ' 元';
                    }
                    return '-';
                })
            ];
        },
        /**
         * vxe-table end
         */
        // 根据id查找凭证
        generalLedgerInfo(id) {
            appMain
                .generalLedgerInfo({}, id)
                .then(res => {
                    if (res.data.code === 20000) {
                        this.tableData = res.data.data;
                    } else {
                        this.$message.error('服务器繁忙，请稍后再试');
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
       saveEdit() {
            bus.$emit('close_current_tags')
        }
    },
    watch: {
    },
    computed: {
        aNum() {
            return 123;
        }
    },
    mounted() {
        var div_height = window.screen.availHeight;
        var height = div_height - 100;
        this.containerHeight = height - 160;
        this.pageTitle = this.$router.currentRoute.meta.title;
    },
    created() {
        //如果有id过来就是修改的
        if (this.$route.query.id) {
            let id = this.$route.query.id;
            //通过id查询对应离职信息
            this.generalLedgerInfo(id);
        } else {
           
        }

    }
};
</script>

<style lang="css" scoped>
.container {
    padding-bottom: 50px;
}
.handle-box {
    padding: 5px 50px;
    width: 100%;
    background-color: #fff;
    position: absolute;
    left: 0;
    bottom: 0px;
    border-bottom: 1px solid #ddd;
    border-top: 1px solid #ddd;
    z-index: 1;
}
.table-form-box{
    padding-bottom: 100px;
}
.table-form-box table {
    background-color: #666;
}
.table-form-box .h3 {
    font-size: 22px;
    text-align: center;
    font-weight: normal;
    padding: 20px 0;
}
.table-form-box table .tr-title td {
    font-size: 14px;
    line-height: 40px;
}
.table-form-box table td,
.table-form-box table th {
    background-color: #fff;
    padding: 4px;
    min-height: 40px;
    font-size: 12px;
}
.color-ff2200 {
    color: #ff2200;
}

</style>